<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name:  Master View Functions
*
* Author: Ray Nowell
*
* Created:  10/01/2010
*
* Description:  Functions used in the master view for the Header and Navigation Poritions of the Pharmacy Intervention App 
*
*/

class Master_view_functions
{
	/** 
	* Returns the url of the currently logged in user
	* 
	* @access public 
	* @return string */ 
	function get_user_facility_url()
	{
		$this->CI =& get_instance();
		$this->CI->load->model('Facility_model');
		$user = $this->CI->ion_auth->get_user(); 
		$facility_id = $user->current_facility_id;
		$facility_row = $this->CI->Facility_model->get_facility_id_record($facility_id);
		return $facility_row->facility_site_url;	
	}
	
	/** 
	* Returns the url of the currently logged in user
	* 
	* @access public 
	* @return string */ 
	function get_user_facility_name()
	{
		$this->CI =& get_instance();
		$this->CI->load->model('Facility_model');
		$user = $this->CI->ion_auth->get_user(); 
		$facility_id = $user->current_facility_id;
		$facility_row = $this->CI->Facility_model->get_facility_id_record($facility_id);
		return $facility_row->facility_name;	
	}
	
	function get_user_facility_list()
	{
		
		$this->CI =& get_instance();
		$this->CI->load->model('Facility_model');
		
		$facility_lookup = $this->CI->Facility_model->get_facility_list();
		$facility_list = set_lookup($facility_lookup,'facility_id','facility_name');
		
		
		return $facility_list;
	}
	
}
